<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .box {
            width: 300px;
            height: 300px;
        }

        .red {
            background-color: #f00;
        }

        .bd {
            border: 5px solid #000;
        }

    </style>
</head>
<body>
    <div id="app">
        <button @click="isRed = !isRed">切换</button>
        <button @click="bd = !bd">切换bd</button>
        <!-- red这个类没有写死，而是根据isRed变量来，isRed为true就有red这个类，为false就没有red这个类 -->
        <div class="box" v-bind:class="{ red: isRed, bd }">我是div</div>
        <div class="box" :class="{ red: isRed, bd }">我是div</div>
        
        <!-- 取出cls1和cls2的值，也就是取到 box和red，让这个h3有box和red类 -->
        <h3 :class="[cls1, cls2]">我是h3</h3>
        <!-- 相当于写了下面的 -->
        <h3 class="box red">我是h3</h3>
    </div>

    <script src="./vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                isRed: true,
                bd: true,
                cls1: 'box',
                cls2: 'red'
            }
        })
    </script>
</body>
</html>